<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!-- 모두선택 설정하는 툴 -->
<script type="text/javascript">
$(document).ready(function(){
	$("input[name=allcheck]").on("click", function(){
		var chk = this.checked;
		$("input[name=pageAccessRight]").each(function(){
			this.checked = chk;
		});
	});
	$("input[name=allcheck]").on("click",function(){
		$("input[name=pageAccessRight]").prop("checked", this.checked);
	});
});
</script>

<script type="text/javascript">
function registerMileageOption(){
	
	if($("#joinMileageOption").val()==''){
		alert("최초가입 적립금 지급액은 필수 사항입니다.");
		$("#joinMileageOption").focus();
		return;
	}
	if(($("#availableMinPriceOption").val()=='')){
		alert("사용가능최저적립금은 필수 사항입니다.");
		$("#availableMinPriceOption").focus();
		return;
	}
	if(($("#availableMaxPriceOption").val()=='')){
		alert("사용가능최대적립금은 필수 사항입니다.");
		$("#availableMaxPriceOption").focus();
		return;
	}

	$.ajax({
		url:"/${initParam.context_root}/myshop/registerMileageOption.do",
		type:"POST",
		data:$("#mileageOptionForm").serialize(),
		success:function(JSON){
			if(JSON.success==1){
				alert("등록이 완료되었습니다.");
			}else if(JSON.success==-1){
				alert("변경되었습니다.");
			}else{
				alert("실패");
			}
			window.close();
		}
	});
}
</script>
<style type="text/css">
 
  	.headline {margin-top: 0px; margin-bottom: 10px;}
  	.headtext {font-weight: bolder; color:#B061BF; margin-top: 20px; margin-bottom: 0px; font-style: 돋음; }
</style>
<br>
<h2 class="headtext">적립금 설정</h2>
<hr class="headline"><br>
<form style="width: 500px;" id="mileageOptionForm">
<h4 align="center"><b>적립금 설정창</b></h4>
<table class="table table-bordered"  align="left" border="3" style="border-collapse:collapse; border-color:#BDBDBD; margin-left: 100px;" >
	<tr >
		<td style="background-color:#453949; color: white;">절삭 기준</td>
		<td>
			<select name="truncationFee">
				<option>10</option><option>100</option><option>1000</option>
			</select>
			<select name="truncationOption"><option >내림</option><option>반올림</option><option>올림</option></select>
		</td>
	</tr>
	<tr>
		<td style="background-color:#453949; color: white;">적립금 비율</td><td><select name="ratio"><option>3</option><option>5</option><option>10</option></select>%</td>
	</tr>
	<tr>
		<td style="background-color:#453949; color: white;">최초가입 적립금 지급액</td><td><input type="text" id="joinMileageOption" name="joinMileageOption" placeholder="${requestScope.mileage.joinMileageOption }"></td>
	</tr>
	<tr>
		<td style="background-color:#453949; color: white;">사용가능최저적립금</td><td><input type="text" id="availableMinPriceOption" name="availableMinPriceOption" placeholder="${requestScope.mileage.availableMinPriceOption }"></td>
	</tr>
	<tr>
		<td style="background-color:#453949; color: white;">사용가능최대적립금</td><td><input type="text" id="availableMaxPriceOption" name="availableMaxPriceOption" placeholder="${requestScope.mileage.availableMaxPriceOption }"></td>
	</tr>
	<tr>
		<td colspan='2' align="center"><input type="button" value="적립금 정보 등록" onclick="registerMileageOption()"></td>
	</tr>
</table>
</form>
